
<!--
  @Descripttion:用户中心-项目评论
  @Author：yejianbo
  @Date：2022年05月26日 12:35:40
-->
<template>
    <section class="page">
        <pageCom>
        <div class="content-page">
            <div class="content">
            <el-breadcrumb
                separator-class="el-icon-arrow-right"
                style="margin-bottom: 20px"
            >
                <el-breadcrumb-item>首页</el-breadcrumb-item>
                <el-breadcrumb-item :to="{ name: 'userCenter' }"
                >用户中心</el-breadcrumb-item
                >
                <el-breadcrumb-item>
                <span style="color: #3d6cb0">项目评价</span>
                </el-breadcrumb-item>
            </el-breadcrumb>
            <p class="page-title">项目评价</p>
            <div class="page-content">
                <div class="search">
                    <img
                        src="@/assets/images/search-icon.png"
                        alt=""
                        class="search-icon"
                    />
                    <el-select
                        v-model="qureyParams.feedbackStatus"
                        style="width: 150px; margin-right: 10px"
                        placeholder="反馈状态"
                        class="search-select"
                        size="mini"
                        clearable
                    >
                        <el-option
                        label="已反馈"
                        :value="1"
                        >
                        </el-option>
                        <el-option
                        label="未反馈"
                        :value="0"
                        >
                        </el-option>
                    </el-select>
                    <el-button size="mini" type="primary" @click="getData">搜索</el-button>
                    <el-button
                        size="mini"
                        style="font-size: 15px; color: #3d6cb0"
                        type="text"
                        @click="clearCondition"
                        >清空筛选条件</el-button
                    >
                </div>
                <el-table
                :data="tableData"
                style="width: 100%;">
                    <el-table-column
                    prop="title"
                    label="项目名称"
                    width="200">
                    <template slot-scope="scope">
                    <p class="product-title-link" @click="linkToProductDetail(scope.row.projectId)">{{ scope.row.title || '--'}}</p>
                    </template>
                    </el-table-column>
                    
                    <el-table-column
                        prop="entryType"
                        label="反馈状态"
                        align="left">
                    <template slot-scope="scope">
                        <!-- // feedbackStatus 反馈状态:1:未反馈2:已反馈 -->
                        <p>{{ feedbackStatusStr[scope.row.feedbackStatus] || '--' }}</p>
                    </template>
                    </el-table-column>
                    <el-table-column
                        align="center"
                        label="操作"
                        width="240">
                        <template slot-scope="scope">
                                <el-button type="text" v-if="scope.row.feedbackStatus === 1" style="margin: 0 10px" @click="getMatchResult(scope.row, 'check')">查看反馈</el-button>
                                <el-button type="text" v-if="scope.row.feedbackStatus === 0" style="margin: 0 10px" @click="getMatchResult(scope.row, 'edit')">提交反馈</el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <div style="display: flex;flex-flow: row nowrap; justify-content: center;padding: 46px 0;">
                    <el-pagination
                        class="bottom-page"
                        background
                        layout="prev, pager, next"
                        :total="total"
                        :page-size="pageSize"
                        :page-sizes="[6, 12, 24, 36, 48]"
                        @size-change="pagesizeHandle"
                        @current-change="currentChange"
                        :current-page="pageNo"
                        >
                        </el-pagination>
                    </div>
                </div>
            </div>
        </div>
        <el-dialog
            title="提示"
            :visible.sync="dialogVisible"
            width="50%"
            >
            <div>
                <div class="result-text">
                    请填写您对参与本次活动的评价及建议
                </div>
                <el-input
                    type="textarea"
                    placeholder="请输入内容"
                    :autosize="{ minRows: 4, maxRows: 6}"
                    v-model="resultDialog.feedbackConnect"
                    maxlength="200"
                    :disabled="!isEdit"
                    show-word-limit
                >
                </el-input>
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisible = false">取 消</el-button>
                <el-button v-if="isEdit" type="primary" @click="updateFeedback()">确 定</el-button>
            </span>
            </el-dialog>
        </pageCom>
    </section>
  </template>
  
  <script>
import pageCom from "@/components/page/index.vue";
  import { getMatchFeedbackList, updateFeedback } from "../../request/api";
  export default {
    // 组件名称
    name: "productComment",
    // 组件参数 接收来自父组件的数据
    props: {},
    // 局部注册的组件
    components: {  pageCom },
    computed: {
    },
    created() {
        this.getData()
    },
    watch: {
    },
    // 组件状态值
    data() {
      return {
        isEdit: true,
        feedbackStatusStr: {
            0: '未反馈',
            1: '已反馈'
        },
        dialogVisible:false,
        resultDialog: {
            feedbackStatus: '',
            "feedbackConnect": '',
            "createTime": '',
            "feedbackTime": '',
            "id": '',
            "projectId": '',
            "studentId": '',
            "title": '',
        },
        productStatus: [
            {
            label: "报名中",
            value: 1,
            },
            {
            label: "已结束",
            value: 2,
            },
        ],
        scheduleTypeList: [
            {label: '初赛',value: '2'},
            {label: '复赛',value: '3'},
            {label: '决赛',value: '4'},
        ],
        scheduleTypeStr: {
            1: '遴选',
            2: '初赛',
            3: '复赛',
            4: '决赛'
        },
        action:
        process.env.VUE_APP_BASE_API + "/app-api/student/web-student/upload",
        tableData: [],
        total: 0,
        pageNo: 1,
        pageSize: 10,
        currentItem: '',
        qureyParams: {
            feedbackStatus: "",
        },
      };
    },
    // 组件方法
    methods: {
        updateFeedback() {
            if (!this.resultDialog.feedbackConnect || this.resultDialog.feedbackConnect.length === 0) {
                this.$message.warning("请填写反馈内容");
                return
            }
            this.resultDialog.feedbackStatus = 1
            updateFeedback(this.resultDialog).then(res => {
                if (res && res.code === 0 ){
                    this.$message.success("反馈成功");
                    this.dialogVisible = false
                    this.getData()
                }
            })
        },
        clearCondition() {
            this.qureyParams = this.$options.data().qureyParams;
            this.getData();
        },
        linkToProductDetail(id) {
            this.$router.push({name: 'productDetail', query: {id: id}})
        },
        linkToProductDetail1(id) {
            this.$router.push({name: 'checkProductDetail', query: {id: id}})
        },
        getMatchResult(item, type) {
            this.currentItem = item
            this.resultDialog = this.$options.data().resultDialog
            Object.assign(this.resultDialog, item)
            this.isEdit = type === 'edit'
            this.dialogVisible = true
        },
        pagesizeHandle(val) {
          this.pageSize = Number(val);
          this.getData();
        },
        currentChange(e) {
            this.pageNo = e;
            this.getData();
        },
        getData() {
            let params = Object.assign({}, {
                pageNo: this.pageNo,
                pageSize: this.pageSize,
            })
            if(this.qureyParams.feedbackStatus) {
                params.feedbackStatus = this.qureyParams.feedbackStatus
            }
            getMatchFeedbackList(params).then(res => {
                if(res && res.code === 0) {
                    const {list, total} = res.data
                    // feedbackStatus 反馈状态:1:未反馈2:已反馈
                    this.tableData = list
                    this.total = total
                }
            })
        },
    },
  };
  </script>
  <style lang="less" scoped>
  
  .page {
    position: relative;
    width: 100%;
    height: 100%;
    min-width: 1000px;
    .content-page {
      position: relative;
      width: 100%;
      height: 100%;
      .names{
        font-size: 15px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #37383D;
        line-height: 21px;
        margin-bottom: 20px;
        display: flex;
        span{
          color: #9597A0;
          width: 78px;
          margin-right: 20px;
        }
      }
  
      .page-title {
        font-size: 25px;
        font-family: PingFangSC-Semibold, PingFang SC;
        font-weight: 600;
        color: #37383D;
        line-height: 36px;
        margin: 30px 0;
      }
      .search {
      display: flex;
      flex-flow: row wrap;
      align-items: center;
      margin-bottom: 20px;
      padding-left: 30px;
      position: relative;
      .search-icon {
        width: 18px;
        height: 20px;
        position: absolute;
        left: 0;
        top: 10px;
      }

      .search-select {
        width: 160px;
        margin-right: 13px;
      }
    }
      .bannber {
        position: relative;
        display: block;
        width: 100%;
        margin-bottom: 25px;
        object-fit: cover;
        height: 170px;
      }
  
      .content {
        position: relative;
        width: 100%;
        max-width: 1200px;
        padding: 23px 30px;
        margin: 0 auto;
  
        .content-title {
          font-size: 18px;
          font-family: PingFangSC-Medium, PingFang SC;
          font-weight: 500;
          color: #37383D;
          line-height: 25px;
          margin-bottom: 16px;
          &::before {
              content: '*';
              color: #F56C6C;
              margin-right: 4px;
          }
        }
        /deep/.el-form-item__label{
          font-size: 16px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
        }
      }
    }
  }
  .product-title-link {
    font-size: 15px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #4677B9;
    line-height: 21px;
    cursor: pointer;
  }
  /deep/ .el-button--text {
    font-size: 15px;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: #4677B9;
    line-height: 21px;
  }
  /deep/ .el-breadcrumb__inner {
    font-size: 18px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #37383d;
    line-height: 28px;
    cursor: pointer;
  }
  .hover-icon {
    cursor: pointer;
  }
  .showAuthentication{
      position: fixed;
      z-index: 2014;
      width: 100%;
      height: 100%;
      left: 0;
      top: 0;
      display: flex;
      justify-content: center;
      align-items: center;
      background: rgba(0, 0, 0, 0.3);
    .showAuthenticationBox{
      width: 360px;
      height: 241px;
      padding: 66px 30px 90px;
      border-radius: 12px;
      background: #fff;
      position: relative;
      .content{
        width: 100%;
        height: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 15px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #37383D;
        line-height: 21px;
      }
      .content2{
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 15px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #37383D;
        line-height: 21px;
      }
      .title{
        position: absolute;
        width: 100%;
        left: 0;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 18px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #37383D;
        line-height: 25px;
        top:25px;
      }
      .title2{
        font-size: 14px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #37383D;
        line-height: 20px;
        margin-bottom: 12px;
      }
      .btns{
        width: 100%;
        height: 40px;
        position: absolute;
        bottom: 40px;
        left: 0;
        display: flex;
        justify-content: space-between;
        padding: 0 40px;
        &>div{
          width: 130px;
          height: 40px;
          display: flex;
          justify-content: center;
          align-items: center;
          font-size: 14px;
          font-size: 14px;
          font-family: PingFangSC-Semibold, PingFang SC;
          font-weight: 600;
          color: #4677B9;
          border: 1px solid #4677B9;
          border-radius: 2px;
          cursor: pointer;
          &.submit{
            background: #4677B9;
            color: #fff;
            border: none;
          }
        }
      }
    }
  }
  .result-title {
    font-size: 20px;
    font-family: PingFangSC-Semibold, PingFang SC;
    font-weight: 600;
    color: #37383D;
    line-height: 28px;
    text-align: center;
    margin: 0 0 30px 0;
}
.result-text {
    font-size: 16px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #37383D;
    line-height: 30px;
    text-indent: 32px;
    margin-bottom: 19px;
}
.result-public-time {
    text-align: right;
    font-size: 14px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #9597A0;
    line-height: 28px;
}
  /deep/ .el-input__suffix{
    display: none;
  }
  /deep/ .el-table th.el-table__cell {
    background: #F5F8FA;
    font-size: 15px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #37383D;
  }
  #app .el-pagination.is-background .el-pager li:not(.disabled).active {
  width: 32px !important;
  height: 32px !important;
}

.el-button--primary {
  width: 64px;
  height: 40px;
  padding: 0;
  background: #4677b9;
  border-radius: 5px;
  font-size: 15px;
  font-family: PingFangSC-Medium, PingFang SC;
  border: none;
  font-weight: 500;
}
.el-button--danger {
  background: #4677b9;
  border: none;
}
  </style>
  